/**************************************************************
 * @file     bsp_led.c
 * @brief    接收队列消息驱动led
 * @author   Ruilist
 * @date     2025-07-30
 * @version  V1.0.0
 * @copyright Copyright (c) 2025
 *
 * @note     1 tab = 4 space
 *
 * @par ??:
 * - V1.0.0 2025-07-30 Ruilist
 *   接收队列消息驱动led
 **************************************************************/

#ifndef __BSP_LED_H__
#define __BSP_LED_H__

//******************************** Includes *********************************//

#include <stdint.h>
#include <stdio.h>

#include "cmsis_os.h"
#include "cmsis_os2.h"
#include "main.h"

#include "queue.h"
#include "stm32f4xx_hal.h"
#include "stm32f4xx_hal_gpio.h"

//******************************** Includes *********************************//

//******************************** Defines **********************************//

#define LED_Pin       GPIO_PIN_13
#define LED_GPIO_Port GPIOC

typedef enum
{
    LED_OK             = 0,         /* Operation completed successfully.  */
    LED_ERROR          = 1,         /* Run-time error without case matched*/
    LED_ERRORTIMEOUT   = 2,         /* Operation failed with timeout      */
    LED_ERRORRESOURCE  = 3,         /* Resource not available.            */
    LED_ERRORPARAMETER = 4,         /* Parameter error.                   */
    LED_ERRORNOMEMORY  = 5,         /* Out of memory.                     */
    LED_ERRORISR       = 6,         /* Not allowed in ISR context         */
    LED_RESERVED       = 0x7FFFFFFF /* Reserved                           */
} led_status_t;

typedef enum
{
    LED_ON             = 0,   /* Operation completed successfully.  */
    LED_OFF            = 1,   /* Operation completed successfully.  */
    LED_TOGGLE         = 2,   /* Operation completed successfully.  */
    LED_BLINK_1_TIMES  = 3,   /* Operation completed successfully.  */
    LED_BLINK_3_TIMES  = 4,   /* Operation completed successfully.  */
    LED_BLINK_10_TIMES = 5,   /* Operation completed successfully.  */
    LED_INITED_VALUE   = 0xFF /* Inited value                    .  */
} led_operation_t;

//******************************** Defines **********************************//

//*********************Thread_Func **********************//

extern osThreadId_t         led_TaskHandle;
extern const osThreadAttr_t led_Task_attributes;

//*********************Thread_Func **********************//

//*********************Queue_Handler ********************//

extern QueueHandle_t led_queue;

//*********************Queue_Handler ********************//

//******************************** Declaring ********************************//

/**
 * @brief   实现led亮灭等状态
 *
 * @param   led_operation    led操作参数
 *
 * @return  函数状态 led_status_t
 *
 */
led_status_t led_on_off( led_operation_t led_operation );

/**
 * @brief   实现led亮灭状态，用于回调函数中调用
 *
 * @param   led_operation    led操作参数
 *
 * @return  函数状态 led_status_t
 *
 */
led_status_t led_on_off_timer_irq( led_operation_t led_operation );

/**
 * @brief   led任务
 *
 * @param   *argument    默认参数
 *
 * @return  无
 *
 */
void led_task_func( void *argument );

/**
 * @brief   TIM2中断回调函数
 *
 * @param   void
 *
 * @return  函数状态 led_status_t
 *
 */
led_status_t led_callback_in_timer( void );

//******************************** Declaring ********************************//

#endif  // End of __BSP_LED_H__
